package cn.wolfcode.business.controller;

import cn.wolfcode.business.domain.BusStatement;
import cn.wolfcode.business.service.BusinessStatementService;
import cn.wolfcode.common.core.controller.BaseController;
import cn.wolfcode.common.core.domain.AjaxResult;
import cn.wolfcode.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/business/statement")
public class BusinessStatementController extends BaseController {
    @Autowired
    private BusinessStatementService businessStatementService;

    @GetMapping("/list")
    public TableDataInfo list(BusStatement busStatement){
        startPage();
        List<BusStatement> list = businessStatementService.selectStatementList(busStatement);
        return getDataTable(list);
    }
    @GetMapping("/{id}")
    public AjaxResult get(@PathVariable Long id){
        return AjaxResult.success(businessStatementService.selectStatementById(id));
    }
    @PostMapping
    public AjaxResult save(@RequestBody BusStatement busStatement) {
        return toAjax(businessStatementService.save(busStatement));
    }
    @PutMapping
    public AjaxResult update(@RequestBody BusStatement busStatement) {
        return toAjax(businessStatementService.update(busStatement));
    }

    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Long id) {
        return toAjax(businessStatementService.deleteStatementById(id));
    }

    @PostMapping("/{id}/appointment")
    public AjaxResult statement(@PathVariable Long id) {
      Long statementId =   businessStatementService.createStatement(id);
        return AjaxResult.success(statementId);
    }

}

